//购物车接口
import request from "@/utills/request";

//获取最新商品列表
export const getNewCartGoods =  (skuId) => {
    return request(`/goods/stock/${skuId}`, 'get')
  }

  //获取对应商品的sku
  export const getCartGoodsSku =  (skuId) => {
    return request(`/goods/sku/${skuId}`, 'get', )
  }

  //合并购物车
  export const mergeLocalCart =  (cartList) => {
    return request(`/member/cart/merge`, 'post', cartList)
  }

  //已登录状态。获取购物车列表
  export const findCartList = () => {
    return request('/member/cart', 'get')
  }
  //已登录状态。加入购物车
  export const insertCart  = ({ skuId, count }) => {
    return request('/member/cart', 'POST', { skuId, count })
  }
  //已登录状态。删除购物车（单个/批量）
  export const deleteCart  = ( ids ) => {
    return request('/member/cart', 'DELETE', { ids })
  }
  //已登录状态。修改购物车商品选中状态
  export const updateCart  = ( {skuId, selected, count} ) => {
    return request(`/member/cart/${skuId}`, 'PUT', {skuId, selected, count})
  }
  //已登录状,全选与取消全选
  export const checkAllCart = ({ selected, ids }) => {
    return request('/member/cart/selected', 'put', { selected, ids })
  }
